package com.lzb.party.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lzb.party.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    //Mybatis访问数据库

    @Select("Select * from user")
    List<User> findAll();

    @Insert("INSERT into user(sname, pass, snum, stage, origin, birth) values " +
            "(#{sname},#{pass}, #{snum},#{stage},#{origin},#{birth})")
    int insert(User user);

    int update(User user);

    @Delete("delete from user where snum = #{snum}")
    Integer deleteById(@Param("snum") String snum);

    @Select("SELECT * FROM `user` where sname like #{sname} && snum like #{snum} limit #{pageNum}, #{pageSize}")
    List<User> selectPage(Integer pageNum, Integer pageSize, String sname, String snum);

    @Select("select count(*) from user where sname like #{sname} && snum like #{snum}")
    Integer selectTotal(String sname, String snum);

    @Select("select count(*) from user where snum like #{snum} && pass like #{pass}")
    Integer login(String snum, String pass);

    @Select("select snum from user where sname like #{sname}")
    String selectsnum(String sname);
}
